package {{package}};

import io.helidon.microprofile.testing.junit5.HelidonTest;
import jakarta.inject.Inject;
import jakarta.ws.rs.client.WebTarget;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

@HelidonTest
class FtResourceTest {
    @Inject
    private WebTarget target;

    @Test
    void testFallback() {
        String response = target
                .path("/ft/fallback/true")
                .request()
                .get(String.class);


        assertThat(response, is("blocked for 100 millis"));

        response = target
                .path("/ft/fallback/false")
                .request()
                .get(String.class);

        assertThat(response, is("Fallback endpoint reached"));
    }

    @Test
    void testRetry() {
        String response = target
                .path("/ft/retry")
                .request()
                .get(String.class);

        assertThat(response, is("failures: 2"));
    }
}